<template>
	<view class="container">
		<view class="con">
			<view class="search">
				<view class="searchs">
					<image src="../../static/images/search.png" mode=""></image>
					<input type="text" value="" placeholder="搜索人名、标题、内容" @change="nav_list" @input="input" :value="search" />
				</view>
				<view>
					<view class="right1">
				
						<picker @change="endTime" :range="array4">
						<!-- //@change用于获取下拉框改变的值，:range用于循环遍历array数组将数组内容循环 -->
										<label class="">{{array4[index4]}}</label>  
						 <!-- //循环array数组index为索引 -->
						</picker>
						<image src="../../static/images/la.png" mode="" @change="endTime" class="la"></image>
					</view>
				</view>
			</view>
		</view>
		<view class="inv-h-w">
		    <view :class="['inv-h',nav_index==index?'inv-h-se':'']" v-for="(item,index) in nav" :key="index" @click="navs(index,item.id)">{{item.name}}</view>
		        <!-- <view :class="['inv-h',Inv==1?'inv-h-se':'']" @click="Inv=1">我是选项卡二</view> -->
		</view>
		<view class="work">
		  	<view class="works"  v-for="(item,index) in works" :key="index" @tap="arrays(item.applyId,item.status)">
				<view class="dong">{{item.applyType}}</view>
				<view class="shen">申请单位：{{item.applyDept}}</view>
				<view class="shen">申请人：{{item.applyUser}}</view>
				<view class="bian">编号：{{item.applyNo}}</view>
				<view class="dai">{{item.status}}</view>
		  	</view>	
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				search:'',
				page:1,
				nav_id:0,
				nav_index:'',
				array4:['全部(3)','人名','标题','内容'],
				index4:0,
				nav: [
					{id:0,name:'已提交'},
					{id:1,name:'待处理'},
					{id:2,name:'已处理'},
					{id:3,name:'抄送人'},
				],
				works:[
					// {
					// 	text1:'动火安全作业票',
					// 	text2:'申请单位：汽机分场',
					// 	text3:'申请人：热机分场汽机水泵班',
					// 	text4:'编号: 196GZ20160401523',
					// },
					// {
					// 	text1:'动火安全作业票',
					// 	text2:'申请单位：汽机分场',
					// 	text3:'申请人：热机分场汽机水泵班',
					// 	text4:'编号: 196GZ20160401523',
					// },
					// {
					// 	text1:'动火安全作业票',
					// 	text2:'申请单位：汽机分场',
					// 	text3:'申请人：热机分场汽机水泵班',
					// 	text4:'编号: 196GZ20160401523',
					// }
				]
			}
		},
		onLoad() {
			this.nav_list();
			console.log(uni.getStorageSync("token"),11111)
		},
		// 监听滚动轴触底
		 onReachBottom:function(){
			this.page++
			this.nav_list(); 
			console.log(1111111)
		 },
		methods: {
			arrays(applyId,status){
				if(status=='草稿'){
					uni.navigateTo({
						url:'cWork/cWork?applyId='+applyId
					});
					}else{
						uni.navigateTo({
							url:'workDetails/workDetails?applyId='+applyId
						});
					}
			},
			changeTab(Inv){
				that.navIdx = Inv;
			},
			
			endTime: function(e) {
			 this.index4 = e.target.value
			 this.jgb=this.array4[this.index4] 
			},
			navs(id,index){
				this.works = [] ;
				this.page = 1;
				this.nav_id=id;
				this.nav_index=index
				this.nav_list()
			},
			nav_list(){
				uni.request({
					url: this.$url + 'apply/my/list',
					header:{
						Authorization:'Bearer '  + uni.getStorageSync("token")
					},
					data:{
						pageNum:this.page,
						pageSize:3,
						queryType:this.nav_id,
						queryMagic:this.search,
						workType:0
					},
					success: (res) => {
						console.log(res,8888)
						if(res.data.code==200){
							this.works=res.data.rows
							this.works = this.works.concat(res.data.rows);
							
							if( this.page > 0 ){
								if(res.data.rows != []){
									this.works = this.works.concat(res.data.rows);
								}
							} else {
								uni.showToast({
									title: '没有更多数据',
									icon: 'none'
								})
							   console.log("error")
							}
						}
					}
				})
			},
			input(e){
				console.log(e.detail.value)
				this.search=e.detail.value
			},
			seek(){
				// uni.request({
				//      url: this.$url + 'getInfo',
				//      method: 'GET',
				// 	 header:{
				// 	       'Authorization': 'Bearer ' + 'eyJhbGciOiJIUzUxMiJ9.eyJsb2dpbl91c2VyX2tleSI6IjcwMzFhZTUzLWQ3NDEtNDlhMS05MWU2LTdjNTA2MjNjYjJjYSJ9.rnpmqoCRKZZm7etVEKXVE7-2GIGqGDUPHQAjxNq__XFyW4g2otDTci8-v6NOS_g3BN4II7bkQfQeFVOWo5kqXA'
				// 	      },
				//      success: (res) => {
				//         console.log(res);
				// 		if(res.data.code==200){
				// 			this.info=res.data.data.userInfo
				// 		}
				// 		console.log(this.info)
				//      },
				//      complete: () => {
				      
				//      },
				//      fail: (e) => {
				//       console.log(e);
				//      }
				// });
			}
		}
	}
</script>

<style lang="scss">
page{
	background-color:#ECECEC;
	.container{
		background-color: #ECECEC;
		.con{
			background-color: #fff;
			.search{
				display: flex;
				align-items: center;
				.searchs{
					margin:25rpx 40rpx;
					display: flex;
					align-items: center;
					width: 400rpx;
					line-height: 80rpx;
					background: #F2F2F2;
					border-radius: 30rpx;
					padding:10rpx 45rpx;
					// margin:0 auto;
					image{
						width: 36rpx;
						height: 36rpx;
					}
					input{
						width: 200rpx;
						background-color: #F2F2F2;	
						font-size: 28rpx;
						border-radius: 12px;
						margin-left: 20rpx;
					}
				}
				.la{
					width: 16rpx;
					height: 10rpx;
					margin-top: 20rpx;
					margin-left: 10rpx;
				}
				text{
					font-size: 32rpx;
					margin-right: 20rpx;
				}
			}
		}
		.inv-h-w{
			background-color: #FFFFFF;
			height:90rpx;
			display: flex;
			justify-content:space-between;
			border-top:1px solid #ECECEC;
			}
		.inv-h{
			font-size: 32rpx;
			// flex: 1;
			text-align: center;
			color:#333333;
			height:90rpx;
			line-height:90rpx;
			width:140rpx;
		}
		.inv-h-se{
			color:#3472FD;
			border-bottom:2px solid #3472FD;
			font-size:32rpx;
		}
		.right1{
			display: flex;flex-direction: row;justify-content: baseline;
			font-size: 30rpx;
		}
		.work{
			.works{
				margin: 20rpx 20rpx;
				background-color: #fff;
				padding: 49rpx 53rpx 0rpx;
				border-radius: 10rpx;
				position: relative;
				.dong,.shen{
					color: #333;
					margin-bottom:15rpx;
				}
				.dong{
					font-size: 28rpx;
					font-weight: 600;
				}
				.shen{
					font-size: 28rpx;
				}
				.bian{
					padding: 31rpx 0;
					color: #999999;
					font-size: 24rpx;
					border-top:1px solid #F4F6F9;
				}
				.dai{
					position: absolute;
					top: 0;
					right: 0;
					width: 150rpx;height: 63rpx;
					line-height: 63rpx;
					text-align: center;					
					background: #07C160;
					border-top-right-radius: 10rpx;
					border-bottom-left-radius: 10rpx;
					font-size: 24rpx;
					color: #fff;
				}
			}
		}
	}
}	
</style>
